﻿Public Class massymptom
    Private SYMPTOM = Nothing
    Private ICD10TM = Nothing
    Private SYMDESC = Nothing
    Private STATUS = Nothing
    Private selectMassymptom = "SELECT `symptom` AS 'รหัสลักษณะการแพ้ยา', `icd10tm` AS 'รหัส ICD-10', `symdesc` AS 'อาการแพ้ยา', `status` AS 'สถานะการเปิดใช้งาน' FROM massymptom"
    'Private selectMasgrpdrg = "SELECT GDCODE, GRPDRG, convert(bit, [STATUS]) FROM MASGRPDRG"

    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection

    Property SYMPTOM_ As Integer
        Get
            Return SYMPTOM
        End Get
        Set(value As Integer)
            SYMPTOM = value
        End Set
    End Property

    Property ICD10TM_ As String
        Get
            Return ICD10TM
        End Get
        Set(value As String)
            ICD10TM = value
        End Set
    End Property

    Property SYMDESC_ As String
        Get
            Return SYMDESC
        End Get
        Set(value As String)
            SYMDESC = value
        End Set
    End Property

    Property STATUS_ As Boolean
        Get
            Return STATUS
        End Get
        Set(value As Boolean)
            If value = True Then
                STATUS = 1
            Else
                STATUS = 0
            End If
        End Set
    End Property

    Property selectMassymptom_ As String
        Get
            Return selectMassymptom
        End Get
        Set(value As String)

        End Set
    End Property

    Public Sub insertMassymptomData()
        Try
            connect = CONDB.NewConnection()
            'connectlocal = conlocal.NewConnection()
            'Dim dischargeID As Integer

            connect.ExecuteNonQuery("INSERT INTO massymptom (icd10tm, symdesc, status) VALUES ('" & ICD10TM & "', '" & SYMDESC & "', '" & STATUS & "')")
            'dischargeID = connect.ExecuteScalar("INSERT INTO masdischarge (DISCHARGE, STATUS) VALUES ('" & masdischargeDescription & "', '" & masdischargeStatus & "'); SELECT LAST_INSERT_ID();")
            'connectlocal.ExecuteNonQuery("INSERT INTO MASDISCHARGE (DISCHGID, DISCHARGE, STATUS) VALUES ('" & dischargeID & "', '" & masdischargeDescription & "', '" & masdischargeStatus & "')")
            MsgBox("ท่านได้ทำการเพิ่มข้อมูลอาการแพ้ยาเรียบร้อยแล้ว")
        Catch ex As Exception
            MsgBox(vbCrLf & ex.Message)
        End Try
        connect.Dispose()
        'connectlocal.Dispose()
    End Sub

    Public Sub editMassymptomData()
        Try
            connect = CONDB.NewConnection()
            'connectlocal = conlocal.NewConnection()

            connect.ExecuteNonQuery("UPDATE massymptom SET icd10tm = '" & ICD10TM & "', symdesc = '" & SYMDESC & "', status = '" & STATUS & "' WHERE symptom = '" & SYMPTOM & "'")
            'connectlocal.ExecuteNonQuery("UPDATE MASDISCHARGE SET DISCHARGE = '" & masdischargeDescription & "', STATUS = '" & masdischargeStatus & "' WHERE DISCHGID = '" & masdischargeID & "'")
            MsgBox("ท่านได้ทำการแก้ไขข้อมูลการแพ้ยาเรียบร้อยแล้ว")
        Catch ex As Exception
            MsgBox(vbCrLf & ex.Message)
        End Try
        connect.Dispose()
        'connectlocal.Dispose()
    End Sub
End Class
